import { mapActions, mapState } from 'vuex'
import LocalCache from '../../utils/localCache'
export default {
  data() {
    return {
      images: [],
      nowChoice: 0,
      page: {
        page: 1,
        pagesize: 10
      }
    }
  },
  async created() {
    if (LocalCache.getLocalCache('miBlogToken')) {
      console.log(1111)
      this.$store.commit('isLogin')
    }
    await this.getUserLabelList()
    await this.getUserInformation()
    await this.getRecommendArticleList(this.page)
    console.log(this.recommendArticleList)
    this.recommendArticleList.forEach(item => {
      if (item.images) {
        this.images.push(item)
      }
    })
    console.log('lalalla', this.images)
    this.nowChoice = this.$route.path.replace('/artlist/', '') - 0
  },
  methods: {
    ...mapActions('Home', ['getUserLabelList', 'getUserInformation']),
    ...mapActions(['getRecommendArticleList']),
    onClick(name, title) {
      console.log(name, title)
      this.$router.push(`/artlist/${name}`)
    },
    onClickImg(data) {
      if (data) {
        this.$router.push(`/artcontent/${data.id}`)
      }
    }
  },
  computed: {
    ...mapState('Home', ['userLabelList']),
    ...mapState(['recommendArticleList'])
  }
}
